<?php $this->setLayout('admin/layout.phtml'); ?>
<div id="import-area">
    <?php echo $table ?>
    <br />
    <?php echo $form ?>
</div>
<div class="info">
    <p><strong><?php __e('Please note: By default, aMember does not change users password and login values to a generated value in cases where an existing email address is found. You may decide to update an existing record, in the next step of the import process, where a matching email or username already exists.') ?></strong></p>
</div>
<script type="text/javascript">
    (function($){
        function setupHooks() {
            $('input.datepicker').datepicker({
                defaultDate: window.uiDefaultDate,
                dateFormat: window.uiDateFormat,
                changeMonth: true,
                changeYear: true
            });

            $("#import-area input, #import-area select").change(function(){
                $(this.form).ajaxSubmit({
                    target: '#import-area'
                });
            })

            $("select[name^=field_]").each(function(){
                if (this.value == 'FIXED') {
                    $(this).next().show();
                } else {
                    $(this).next().hide();
                }
            });
            $("select[name^=field_]").change(function(){
                if (this.value == 'FIXED') {
                    $(this).next().show();
                } else {
                    $(this).next().hide();
                }
            });
            $("input[type=button]").click(function(){
                this.form.action = this.form.action.replace(/(\/)[a-z]+(\/*)$/, '$1back$2');
                this.form.submit();
            })

        }

        $(function(){
            $('#import-area').ajaxSuccess(function(){
                setupHooks();
            });
            setupHooks();
        });
    })(jQuery)
</script>
